package edu.stu.book.book.keeping.component

import android.content.Context
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import edu.stu.book.book.keeping.R
import edu.stu.book.book.keeping.extensions.popTip
import edu.stu.book.book.keeping.utils.ColorUtils

@Composable
fun IconText(
    title: String, icon: ImageVector, context: Context, onclick: () -> Unit
) {
    Column(
        horizontalAlignment = androidx.compose.ui.Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center,
        modifier = Modifier.clickable(indication = null,
            interactionSource = remember { MutableInteractionSource() }) {
            onclick.invoke()
        },
    ) {

        Icon(
            modifier = Modifier.size(24.dp),
            imageVector = icon,
            contentDescription = title,
            tint = ColorUtils.getColor(context)
        )

        Spacer(Modifier.padding(top = 4.dp))

        Text(
            title, style = TextStyle(
                Brush.verticalGradient(
                    colors = listOf(
                        ColorUtils.getColor(context, R.color.main_color),
                        Color.Black,
                    )
                )
            )
        )
    }
}